package com.paad.todolist;

import android.content.Context;
import java.util.*;
import android.view.*;
import android.widget.*;

public class SquadAdapter extends ArrayAdapter<Squad> {

  int resource_id;

  public SquadAdapter(Context _context, 
                             int _resource_id, 
                             List<Squad> _items) {
    super(_context, _resource_id, _items);
    resource_id = _resource_id;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LinearLayout checklistView;

    Squad squad = getItem(position);
    
    String name = squad.name;


    if (convertView == null) {
      checklistView = new LinearLayout(getContext());
      String inflater = Context.LAYOUT_INFLATER_SERVICE;
      LayoutInflater vi = (LayoutInflater)getContext().getSystemService(inflater);
      vi.inflate(resource_id, checklistView, true);
    } else {
      checklistView = (LinearLayout) convertView;
    }

    TextView taskView = (TextView)checklistView.findViewById(R.id.shoppinglist_text);
      
    taskView.setText(name);

    return checklistView;
  }
}
